package logic

import (
	"baidu/baidurpc/baidurpc"
	"baidu/baidurpc/internal/svc"
	"baidu/modil/mysql"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type TextLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewTextLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TextLogic {
	return &TextLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *TextLogic) Text(in *baidurpc.TextRequest) (*baidurpc.TextResponse, error) {
	// todo: add your logic here and delete this line
	text := mysql.Text{
		TypesId: in.TypeId,
		Text:    in.Text,
	}
	mysql.DB.Debug().Create(&text)
	return &baidurpc.TextResponse{
		TextId: int64(text.ID),
	}, nil
}
